package com.iot08.api.config.properties;

import com.iot08.common.utils.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @Description:
 * @time: 2020/12/16 11:41
 * @author: Rock
 */
@Configuration
//如果 加上 file: 可以指定jar包外根目录的相对文件路径
@PropertySource(value = "file:config/list-data.properties", encoding = "gbk")
@ConfigurationProperties(prefix = "list")
@Component
@Slf4j
public class ListDataProperties {

    private List<Map<String, Object>> flow;

    private Map<String, Map<String, Object>> channelMap;

    private List<String> channel;

    private List<String> amapWebKey;

    private List<String> amapLBSKey;

    private List<String> amapBdWebLBSKey;

    public void setFlow(List<Map<String, Object>> flow) {
        for (Map<String, Object> map : flow) {
            if (StringUtil.isNumeric(map.get("ident"))) {
                map.put("ident", Integer.parseInt(map.get("ident").toString()));
            }
            if (StringUtil.isNumeric(map.get("value"))) {
                map.put("value", Integer.parseInt(map.get("value").toString()));
            }
        }
        this.flow = flow;
    }

    public List<Map<String, Object>> getFlow() {
        return this.flow;
    }

    public List<String> getChannel() {
        return channel;
    }

    public void setChannel(List<String> channel) {
        this.channel = channel;
    }

    public Map<String, Map<String, Object>> getChannelMap() {
        return channelMap;
    }

    public void setChannelMap(Map<String, Map<String, Object>> channelMap) {
        this.channelMap = channelMap;
    }

    public List<String> getAmapWebKey() {
        return amapWebKey;
    }

    public void setAmapWebKey(List<String> amapWebKey) {
        this.amapWebKey = amapWebKey;
    }

    public List<String> getAmapLBSKey() {
        return amapLBSKey;
    }

    public void setAmapLBSKey(List<String> amapLBSKey) {
        this.amapLBSKey = amapLBSKey;
    }

    public List<String> getAmapBdWebLBSKey() {
        return amapBdWebLBSKey;
    }

    public void setAmapBdWebLBSKey(List<String> amapBdWebLBSKey) {
        this.amapBdWebLBSKey = amapBdWebLBSKey;
    }
}
